#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> bubbleSort(vector<int> v)
{
    for(int i=0;i<v.size();i++)
    {
        for(int j=0;j<v.size()-1-i;j++)
        {
            if(v[j]>v[j+1])
            {
                swap(v[j],v[j+1]);
            }
        }
        cout<<"Iteration "<<i+1<<":"<<endl;
        for(int c=0;c<v.size();c++)
        {
            cout<<v[c]<<" ";
        }
        cout<<endl;
    }
    return v;
}
int main()
{
    cout<<"Enter the numbers:"<<endl;
    vector<int> v;
    int n;
    while(n!=-1)
    {
        cin>>n;
        v.push_back(n);
    }
    v.pop_back();
    vector<int> result = bubbleSort(v);
    cout<<"Sorted array:"<<endl;
    for(int i=0;i<result.size();i++)
    {
        cout<<result[i]<<" ";
    }
    return 0;
}